<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ElectricCollector extends Model
{
    public $timestamps = false;
    protected $connection = 'mysql_center';
    protected $table = 'electric_collector';

    /**
     * 2021/3/15--15:25
     * @effect:关联区域列表
     * @return HasOne
     * @author:苏冬冬
     * @QQ:1299273928
     * @method:one_community
     */
    public function one_community(): HasOne
    {
        return $this->hasOne(ElectricCommunity::class, "id", "community_id")->selectRaw("id,name");
    }

    /**
     * 2021/3/15--15:24
     * @effect:关联代理商
     * @return HasOne
     * @author:苏冬冬
     * @QQ:1299273928
     * @method:one_agent
     */
    public function one_agent(): HasOne
    {
        return $this->hasOne(ElectricPlatformAgent::class, 'id', 'agent_id')->selectRaw('id,agent_name,agent_mobile');
    }

    public function addMeter(Request $request)
    {

    }
}
